Tricky one, this.....

The game would randomly crash.

So I set to work on trying to repair it. 10/4/2019

1st.... Locate the crash point. It would usually crash at the end of drawing the course, before the player, hole number etc appears on screen.

So I got a broken snapshot, and found out exactly where the error occurred.

I found that when the screen draw routine accessed the table at location 37043, and subsequently jumped to 34513, a RET, it would go haywire. Setting this address to 36389, which appeared to be the end of the draw routine, fixed that error.

POKE 37043,37:POKE 37044,142

This let me play through 18 holes. I'd never done that before (and i'd been on/off trying to fix it for 10 years!, invariably giving up on each occasion). But then I tested course 2. At hole 1, Just use 5 Iron and hit full. The ball will hit the post, and a short tap in and onto hole 2..... Bam! It freezes while drawing the hole. Start at hole 3 then goto hole 2, it works.

A memory differential showed a difference in location 37898, and poking that address with 10 before loading the troublesome hole 2 made it work. Further investigation showed this address changes value every time a different club is selected, so why changing it made any difference I have no idea. Since it later gets poked to "1 Wood" i set this address to 10 after loading any hole.

Upon further testing the game still froze every now and again, it seemed to do it particularly when hitting past the green so the course renders looking back towards the tee. I could not find this bug at all. It was calling to a routine which PUSHed HL, then EX (SP),HL and it would fill the stack down with rubbish, trying to add a POP made it return to the main screen or crash, and it seemed the same routine was working correctly on other occasions. 

So I made a 128K version with each course occupying 1 RAM page, and the remaining page for storing a buffer. After each hole is loaded, it copies itself to the buffer. If the game freezes (or even if you have a really bad hole!!! Naughty Naughty) then pressing BREAK will restore the buffer and re-start the hole.

Nugget Apr 2019

